<?php

if (Layout::o()->enabled('main_menu')) {

if (Auth::o()->is('register')) {

    $items = array();
   // $items[0] = '<li class="not-child"><span class="this-user">'.Auth::o()->name().':</span></li>';
    $after_selected = false;
    $count = 0;

    foreach (Layout::o()->widget['menu']->getByTags(array('top')) as $item) {
        if ($item->name == 'login') {
            continue;
        }
        $add_class_body = "sys_clear";
        if (++$count==1) {
            $add_class_body .= strlen($add_class_body) ? ' ' : '';
            $add_class_body .= 'first-child';
        }
        if ($item->active) {
            $add_class_body .= strlen($add_class_body) ? ' ' : '';
            $add_class_body .= 'selected-link';
            $after_selected = true;
        } elseif ($after_selected) {
            $add_class_body .= strlen($add_class_body) ? ' ' : '';
            $add_class_body = 'after-selected-link';
            $after_selected = false;
        }
        $add_class = strlen($add_class_body) ? " class=\"{$add_class_body}\"" : "";
        $add_id = strlen($item->ident) ? 'menu-item-'.$item->ident : '';
        $add_id = strlen($add_id) ? ' id="'.$add_id.'"' : '';
        $str = '<td class="sys_clear"><div '.$add_id.$add_class.'>';
        if ($item->active) {
            if ($item->current) {
                $str .= '<span>'.$item->title.'</span>';
            } else {
                $str .= '<a href="'.$html->url($item->url_with_params).'">'.$item->title.'</a>';
            }
        } else {
            $str .= '<a href="'.$html->url($item->url_with_params).'">'.$item->title.'</a>';
        }
        $str .= '</div></td>';
        $items[] = $str;
    }

    $items = array_reverse($items);

    ?><div id="top-items" class="sys_layout"><?php
        ?><table id="top-items-container" class="sys_clear" cellpadding="0"><?php
        ?><tr class="sys_clear"><?php
            $items = array_reverse($items);
            $count = count($items);
            $i = 0;
            foreach ($items as $item) {
                echo $item;
            }
        ?></tr><?php
        ?></table><?php
    ?></div><?php

}

}

?>